<!-- Horizontal Form -->
<div class="box box-info">
    <div class="box-header with-border">
        <h3 class="box-title">修改密码</h3>
    </div>
    <!-- /.box-header -->
    <!-- form start -->
    <form class="form-horizontal">
        <div class="box-body">
            <div class="form-group">
                <label class="col-sm-2 control-label" for="pwdId">原密码</label>
                <div class="col-sm-10">
                    <input class="form-control" id="pwdId" name="password" placeholder="原密码" type="password">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label" for="newPwdId">新密码</label>

                <div class="col-sm-10">
                    <input class="form-control" id="newPwdId" name="newPwd" placeholder="新密码" type="password">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label" for="cfgPwdId">密码确认</label>

                <div class="col-sm-10">
                    <input class="form-control" id="cfgPwdId" name="cfgPwd" placeholder="密码确认" type="password">
                </div>
            </div>

        </div>
        <!-- /.box-body -->
        <div class="box-footer">
            <button class="btn btn-default btn-cancel" type="button">Cancel</button>
            <button class="btn btn-info pull-right btn-save" type="button">Save</button>
        </div>
        <!-- /.box-footer -->
    </form>
</div>
<script type="text/javascript">
    $(function () {
        $(".box-footer")
            .on("click", ".btn-cancel", doCancel)
            .on("click", ".btn-save", doUpdateObject)
    });

    function doCancel() {
        $("#mainContentId").html("");
    }

    function doUpdateObject() {
        //1.获取用户提交数据
        var params = {
            sourcePassword: $("#pwdId").val(),
            newPassword: $("#newPwdId").val(),
            configPassword: $("#cfgPwdId").val()
        }
        //2.定义请求的url
        var url = "user/doUpdatePassword"
        //3.异步提交请求,执行更新操作
        $.post(url, params, function (result) {
            if (result.state == 1) {
                alert(result.message);
                //location.href="doLoginUI?t="+Math.random();
                location.href = "doLogout?t=" + Math.random();
            } else {
                alert(result.message);
            }
        })
    }
</script>

    
    